<?php
class Admin_Form_Article extends Zend_Form {

	public function __construct($option = null) {
		parent::__construct ( $option );
		
		$title = new Zend_Form_Element_Text ( 'title' );
		$title->setRequired ( true )
			->setAttrib ( 'class', 'input-block-level' )
			->setAttrib ( 'placeholder', 'Nhập tiêu đề bài viết...' )
			->addFilter ( 'StringTrim' )
			->setDecorators ( array (
				'ViewHelper' 
		) );
		
		$alias = new Zend_Form_Element_Text ( 'alias' );
		$alias->setAttrib ( 'class', 'input-block-level' )
			->setDecorators ( array (
				'ViewHelper' 
		) );
		
		$categoryModel = new Admin_Model_Category ();
		$categorys = $categoryModel->getFetchPairs ();
		$categorys [''] = '[-- Chọn danh mục --]';
		ksort ( $categorys );
		
		$categoryId = new Zend_Form_Element_Select ( 'category_id' );
		$categoryId->addFilter ( 'StringTrim' )
			->setMultiOptions ( $categorys )
			->setRequired ( true )
			->removeDecorator ( 'label' );
		
		$image = new Zend_Form_Element_File ( 'image' );
		$image->setRequired ( true )
			->addValidator ( 'NotEmpty' )
			->removeDecorator ( 'label' );
		
		$intro = new Zend_Form_Element_Textarea ( 'intro' );
		$intro->setRequired ( true )
			->setAttrib ( 'style', 'resize: vertical; width:98%; height: 100px;' )
			->setAttrib ( 'COLS', '80' )
			->setAttrib ( 'ROWS', '5' )
			->setDecorators ( array (
				'ViewHelper' 
		) );
		
		$content = new Zend_Form_Element_Textarea ( 'content' );
		$content->setAttrib ( 'COLS', '40' )
			->setAttrib ( 'ROWS', '2' )
			->setDecorators ( array (
				'ViewHelper' 
		) );
		
		$this->addElements ( array (
				$title,$alias,$keyword,$categoryId,$summary,$content 
		) );
	}
}